﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Text;

namespace Bussiness_Objects
{

    /// <summary>
    /// Thong tin Phieu Nhap Sach
    /// ---PHIEUNHAPSACH(SoPNS,NgayLap,TongTien)
    /// </summary>
    public class PhieuNhapSach : BusinessObjects
    {
        public PhieuNhapSach()
        {
            SoPNS = Int16.MaxValue;            
            TongTien = Int16.MaxValue;
        }

        public PhieuNhapSach(int _soPNS, string _ngLap, int _togTien)
        {
            SoPNS = _soPNS;
            NgayLap = _ngLap;
            TongTien = _togTien;
        }

        public void SetParameterByID()
        {
            parms = new object[1];
            SqlParameter _parm = new SqlParameter(parSoPNS, SoPNS);
            parms[0] = _parm;
        }

        public override void SetParameterInsert()
        {
            parms = new object[3];
            SqlParameter _parm = new SqlParameter(parNgayLap, NgayLap);
            parms[0] = _parm;

            _parm = new SqlParameter(parTongTien, TongTien);
            parms[1] = _parm;

            _parm = new SqlParameter();            
            _parm.ParameterName = parSoPNS;
            _parm.SqlDbType = SqlDbType.Int;            
            _parm.Direction = ParameterDirection.Output;
            parms[2] = _parm;
        }

        public override void SetParameterUpdate()
        {
            parms = new object[3];
            SqlParameter _parm = new SqlParameter(parNgayLap, NgayLap);
            parms[0] = _parm;

            _parm = new SqlParameter(parTongTien, TongTien);
            parms[1] = _parm;

            _parm = new SqlParameter(parSoPNS, SoPNS);
            parms[2] = _parm;
        }

        public void SetParameterDelete()
        {
            parms = new object[1];
            SqlParameter _parm = new SqlParameter(parSoPNS, SoPNS);
            parms[0] = _parm;
        }

        public int SoPNS { get; set; }
        private const string parSoPNS = "@SoPNS";

        public string NgayLap { get; set; }
        private const string parNgayLap = "@NgayLap";

        public long TongTien { get; set; }
        private const string parTongTien = "@TongTien";
    }
}
